package priv.yan;

import java.util.Scanner;
import java.math.BigDecimal;

public class Calculator {
    public static void main(String[] args) {
        f0();
    }

    private static void f0() {
        while (true){
            Scanner  input=new Scanner(System.in);
            System.out.println("输入你要计算的第一个数:");
            BigDecimal a =input.nextBigDecimal();
            System.out.println("输入你要使用的运算符(+ - * /):");
            String c=new Scanner(System.in).nextLine();
            System.out.println("输入你要计算的第二个数:");
            BigDecimal b=input.nextBigDecimal();

            switch  (c){
                case"+":
                    f1(a,b);
                    break;
                case"-":
                    f2(a,b);
                    break;
                case"*":
                    f3(a,b);
                    break;
                case"/":
                    f4(a,b);
                    break;
                default:
                    System.out.println("输入的运算符无法使用!");
            }
            System.out.println("如果你想退出则输入1,如果想继续则输入2");
            int flag=input.nextInt();
            if (flag==1)  break;

        }
    }

    public static void f1(BigDecimal a,BigDecimal b) {

        System.out.println(a+"+"+b+"="+(a.add(b)));
    }
    public static void f2(BigDecimal a,BigDecimal b) {

        System.out.println(a+"-"+b+"="+(a.subtract(b)));
    }
    public static void f3(BigDecimal a,BigDecimal b) {

        System.out.println(a+"*"+b+"="+(a.multiply(b)));
    }
    public static void f4(BigDecimal a,BigDecimal b) {

        System.out.println(a+"/"+b+"="+(a.divide(b)));
    }
}
